﻿using System;

namespace Program14
{
    public enum Gender
    {
        男,
        女,
        其他
    }
    public enum QQState
    {
        online = 1,
        offline = 0,
        leave = 2,
        busy = 3,
        Qme = 4
    }
    class Program
    {

        static void Main(string[] args)
        {
            #region 将INT转换为枚举类型
            QQState state = QQState.online;
            int n = (int)state;
            Console.WriteLine(n);
            #endregion

            #region 将枚举类型转换为INT
            int i1 = 3;
            int i2 = 5;
            var state1 = (QQState)i1;
            var state2 = (QQState)i2;
            Console.WriteLine(state1 + ","+ state2);
            #endregion

            #region 将字符串类型转换为枚举
            string s = "其他";
            Gender g = (Gender)Enum.Parse(typeof(Gender), s);
            Console.WriteLine(g);
            #endregion
        }


    }
}
